package org.chronologger.poppaea.client;

import java.sql.Time;

import org.chronologger.poppaea.client.domain.ChronologyData;

public abstract class PositionResolver {

	private ChronologyData data;
	/**
	 * in Pixels per Day
	 */
	protected int preferredResolution;

	public PositionResolver(ChronologyData data) {
		this.data = data;
	}

	protected ChronologyData getData() {
		return data;
	}

	/**
	 * returns the position in pixels for a given time
	 * 
	 * @param time
	 *            time in milliseconds
	 * @return
	 */
	public abstract int getPosition(Long time);

	/**
	 * returns the time for a given position (in pixels)
	 * 
	 * @param position
	 * @return time in milliseconds
	 */
	public abstract Long getTime(int position);

	/**
	 * returns the total width of the timeline
	 * 
	 * @return width in pixels
	 */
	public abstract int getWidth();

	/**
	 * returns the position corresponding to a given time
	 * 
	 * @param time the time as a Time object
	 * @return position in pixels
	 */
	public int getPosition(Time time) {
		return getPosition(time.getTime());
	}
	
	public void setPreferredResolution(int pixelsPerDay) {
		preferredResolution = pixelsPerDay;
	}
	
	public int getPreferredResolution() {
		return preferredResolution;
	}
	
}
